import time

import appium
from appium import webdriver
from selenium.webdriver.common.by import By

a={
  "platformName": "android",
  "deviceName": "127.0.0.1:7555",
  "appPackage": "com.xueqiu.android",
  "appActivity": ".view.WelcomeActivityAlias",
  "noReset": "true",
  "autoGrantPermissions": "true",
  "skipDeviceInitialization": "true"
}
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',a)
driver.implicitly_wait(20)

time.sleep(10)
I = driver.get_window_size()
print(I)
time.sleep(3)
s_x = int(I['width'])*0.5
e_x = int(I['width'])*0.5
s_y = int(I['height'])*0.3
e_y = int(I['height'])*0.65
driver.swipe(s_x,e_y,e_x,s_y,1000)
time.sleep(10)
driver.swipe(s_x,s_y,e_x,e_y,1000)
el = driver.find_element(By.ID,"com.xueqiu.android:id/home_search")
el.click()
el1 = driver.find_element_by_id("com.xueqiu.android:id/search_input_text")
el1.send_keys("alibaba")
el2 = driver.find_element_by_xpath("//*[@resource-id='com.xueqiu.android:id/name' and @text='阿里巴巴']")
el2.click()
time.sleep(3)
el3 = driver.find_element_by_xpath("//*[@resource-id='com.xueqiu.android:id/title_text' and @text='股票/基金']").click()
el4 = driver.find_element_by_xpath("//*[@resource-id='com.xueqiu.android:id/stockName' and @text='阿里巴巴']")